package org.rrd.kafka.phoneix.client.api;

import lombok.extern.slf4j.Slf4j;

import java.sql.*;

/**
 * @program: kafka-phoneix
 * @description:
 * @author: sunteng
 * @create: 2020-03-16 16:31
 **/
@Slf4j
public class PhoenixApiUtil {

    //       private static final String DBURL = "jdbc:phoenix:10.10.12.215,10.10.12.216,10.10.12.129:2181:/hbase";
    private static final String DBURL = "jdbc:phoenix:172.16.1.90,172.16.1.91,172.16.2.148:2181:/hbase";

    public static void selectAll() throws SQLException {

        ResultSet rset = null;

        Connection con = DriverManager.getConnection(DBURL);

        PreparedStatement statement = con.prepareStatement("select * from YEEPAY_API_LOG");
        rset = statement.executeQuery();
        while (rset.next()) {
            log.info(rset.toString());
        }
        statement.close();
        con.close();
    }

    public static void selectByWhere() throws SQLException {

        ResultSet rset = null;

        Connection con = DriverManager.getConnection(DBURL);

        PreparedStatement statement = con.prepareStatement("select * from test");
        rset = statement.executeQuery();
        while (rset.next()) {
            log.info(rset.toString());
        }
        statement.close();
        con.close();
    }


    public static void main(String[] args) throws SQLException {

        selectAll();
    }

}
